unsigned int cet_converted:1; /* strings are converted to UTF8; interesting only for input */
} wp_flags;
-typedef struct url_link {
- struct url_link *url_next;
- char *url;
- char *url_link_text;
-} url_link;
-
/*
* This is a waypoint, as stored in the GPSR. It tries to not
* cater to any specific model or protocol. Anything that needs to
* afterthought and I don't want to change our data structures.
* So we have the first in the waypoint itself and subsequent
* ones in a linked list.
+ * We also use an implicit anonymous union here, so these three
+ * members must match struct url_link...
*/
struct url_link *url_next;
char *url;
int request_terminate;
} posn_status;
+/*
+ * Structures and functions for multiple URLs per waypoint.
+ */
+typedef struct url_link {
+ struct url_link *url_next;
+ char *url;
+ char *url_link_text;
+} url_link;
+
+void add_url(waypoint *wpt, char *link, char *url_link_text);
+
+
+
typedef void (*ff_init) (char const *);
typedef void (*ff_deinit) (void);
typedef void (*ff_read) (void);
static gbfile *fd;
static gbfile *ofd;
static short_handle mkshort_handle;
+static const char *link_url;
+static char *link_text;
static const char *input_string = NULL;
static int input_string_len = 0;
break;
case tt_wpt_link:
if (0 == strcmp(attr[0], "href")) {
- wpt_tmp->url = xstrdup(attr[1]);
+ link_url = attr[1];
}
break;
+ case tt_wpt_link_text:
+ link_text = cdatastr.mem;
+ break;
case tt_rte:
rte_head = route_head_alloc();
route_add_head(rte_head);
wpt_tmp->url = xstrdup(cdatastrp);
break;
case tt_wpt_urlname:
- case tt_wpt_link_text:
wpt_tmp->url_link_text = xstrdup(cdatastrp);
break;
+ case tt_wpt_link: {
+ char *lt = link_text;
+ if (lt) {
+ lt = xstrdup(lrtrim(link_text));
+ }
+
+ fprintf(stderr, "Here %s/%s\n", link_url, lt);
+ add_url(wpt_tmp, xstrdup(link_url), lt);
+ link_text = NULL;
+ }
+ break;
case tt_wpt:
waypt_add(wpt_tmp);
logpoint_ct = 0;
{
char *tmp_ent;
- if (waypointp->url) {
- tmp_ent = xml_entitize(waypointp->url);
- if (gpx_wversion_num > 10) {
-
+ if (waypointp->url == NULL) {
+ return;
+ }
+
+ if (gpx_wversion_num > 10) {
+ url_link *tail;
+ for (tail = (url_link *)&waypointp->url_next; tail; tail = tail->url_next) {
+ tmp_ent = xml_entitize(tail->url);
gbfprintf(ofd, " <link href=\"%s%s\">\n",
urlbase ? urlbase : "", tmp_ent);
write_optional_xml_entity(ofd, " ", "text",
- waypointp->url_link_text);
+ tail->url_link_text);
gbfprintf(ofd, " </link>\n");
- } else {
- gbfprintf(ofd, " <url>%s%s</url>\n",
- urlbase ? urlbase : "", tmp_ent);
- write_optional_xml_entity(ofd, " ", "urlname",
- waypointp->url_link_text);
+ xfree(tmp_ent);
}
+ } else {
+ tmp_ent = xml_entitize(waypointp->url);
+ gbfprintf(ofd, " <url>%s%s</url>\n",
+ urlbase ? urlbase : "", tmp_ent);
+ write_optional_xml_entity(ofd, " ", "urlname",
+ waypointp->url_link_text);
xfree(tmp_ent);
}
}